/*
 * @Author: Mainul Islam
 */

package edu.uta.cse.randomgraph.gui;

import java.awt.Graphics;
import javax.swing.JPanel;

import edu.uta.cse.randomgraph.graph.MyGraph;

public class MyJPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	
	private MyGraph gr;
	
	public MyJPanel() {
	}
	
	public MyJPanel(MyGraph mg) {
		this.gr = mg;
	}

	public MyGraph getMyGraph() {
		return this.gr;
	}
	
	public void setMyGraph(MyGraph mg) {
		this.gr = mg;
	}
	
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		
		if(gr == null)
			return;
		
		int currWidth = this.getWidth();
		int currHeight = this.getHeight();
		gr.drawGraph(currWidth, currHeight, g);
		gr.setPrevHeightWidth(currWidth, currHeight);
	}
	
}
